import request from "@/utils/request";

export function getList(params) {
  return request({
    url: "/drill/list",
    method: "get",
    params,
  });
}

export function handleAdd(data) {
  return request({
    url: "/drill",
    method: "post",
    data,
  });
}

export function handleDelete(data) {
  return request({
    url: "/drill/" + data,
    method: "Delete",
  });
}
export function handleEdit(data) {
  return request({
    url: "/drill",
    method: "put",
    data,
  });
}

export function getDetails(params) {
  return request({
    url: "/drill/" + params,
    method: "get",
  });
}

// 逆地理编码
export function getAddress(lon,lat) {
  return request({
    url: "/device/getAddress/" + lon + "/" + lat,
    method: "get",
  });
}

// 查询省市区
export function getCity() {
  return request({
    url: "/chinaArea/list",
    method: "get",
  });
}

// 获取经纬度
export function getLnglat(data) {
  return request({
    url: "/addressToMap/addressMap",
    method: "post",
    data: data,
  });
}
// 设备对象
export function getDevice(params) {
  return request({
    url: "/device/drillDevice",
    method: "get",
    params,
  });
}

// 推送标识
export function getPushIndex(data) {
  return request({
    url: "/drillPushTotalLog",
    method: "post",
    data,
  });
}

// 推送
export function handlePush(data) {
  return request({
    url: "/drillPushLog",
    method: "post",
    data,
  });
}

// 推送记录
export function getPushLog(data) {
  return request({
    url: "/drillPushTotalLog/byDrillId/" + data,
    method: "get",
  });
}

// 推送失败记录
export function getFailLog(params) {
  return request({
    url: "/drillPushLog/logList",
    method: "get",
    params,
  });
}

// 本地预测烈度
export const getLevel = () => {
  return request({
    url: "/warningLevelConfig/getInfo",
    method: "get",
  });
};
// 本地预测烈度保存
export const saveLevel = (data) => {
  return request({
    url: "/warningLevelConfig",
    method: "post",
    data,
  });
};

// 倒计时
export const warningCountdown = (data) => {
  return request({
    url: "/drill/warningCountdown",
    method: "get",
    params: data,
  });
};


export const getDefaultConfig = (deviceId) => {
  return request({
    url: "levelConfig/getDefaultConfig/"+deviceId,
    method: "get",
  });
};